package com.zyh.controller;

import com.zyh.pojo.Post;
import com.zyh.service.PostService;
import com.zyh.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class TimelineController {
    @Autowired
    PostService postService;
    @Autowired
    UserService userService;

    /**
     * 获取所有用户和所有用户的文章
     * @param model
     * @return
     */
    @GetMapping("/timeline")
    public String timeline(Model model){
        List<Post> posts=postService.findAll();
        model.addAttribute("posts",posts);
        model.addAttribute("users",userService.findAllUserName());
        return "timeline";
    }
}
